import request from "@/utils/request.js";

const Api = {
    create: "/v1/system/user",
    export: "/v1/system/user/export",
    delete: "/v1/system/user/",
    batchDelete: "/v1/system/user/batch/del",
    update: "/v1/system/user/",
    updateRolePermission: "/v1/system/user/permission/",
    getList: "/v1/system/user",
    getObj: "/v1/system/user/",
}

/**
 * 创建用户
 */
export const create_user = (data) => {
    return request({
        url: Api.create,
        method: "POST",
        data,
    });
};

/**
 * 导入用户
 */
export const export_user = (data) => {
    return request({
        url: Api.export,
        method: "POST",
        headers: {
            "Content-Type": "multipart/form-data",
        },
        data,
    });
};

/**
 * 删除用户
 */
export const delete_user = (id) => {
    return request({
        url: Api.delete + id,
        method: "DELETE",
    });
};

/**
 * 更新用户
 */
export const update_user = (id, data) => {
    return request({
        url: Api.update + id,
        method: "PUT",
        data,
    });
};

/**
 * 获取分页用户列表
 */
export const get_user_list = (params) => {
    return request({
        url: Api.getList,
        method: "GET",
        params,
    });
};

/**
 * 获取用户
 */
export const get_user_obj = (id) => {
    return request({
        url: Api.getObj + id,
        method: "GET",
    });
};